﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.UI.Selection;
using YArchitech.Controls;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YArchitech.Revit;
using Microsoft.Office.Interop.Word;

namespace YArchitech.Plumbing
{
	public partial class FireExtinguisherCalulate : System.Windows.Forms.Form
	{
        public FireExtinguisherCalulate(Autodesk.Revit.DB.Document doc, Autodesk.Revit.UI.Selection.Selection sel)
		{
			this.InitializeComponent();
			//base.Icon = Resource.YArchitechIcon;
			this.doc = doc;
			this.sel = sel;
			this.initParameterSetting();
			this.InitDataGridView();
			this.rdohand.Checked = true;
			this.rdojibie.Checked = true;
			this.toolTip.SetToolTip(this.btnArea, "图面拾取面积后用ESC或者右键取消来完成操作");
		}

		private void rdoup_CheckedChanged(object sender, EventArgs e)
		{
		}

		private void rdodown_CheckedChanged(object sender, EventArgs e)
		{
		}

		private void btnCalulate_Click(object sender, EventArgs e)
		{
			string str;
			if (this.rdoA.Checked)
			{
				this.isA = true;
				str = "A";
			}
			else
			{
				this.isA = false;
				str = "B";
			}
			if (this.rdomuch.Checked)
			{
				this.strclass = this.rdomuch.Text;
				if (this.rdoA.Checked)
				{
					this.U = 100.0;
					this.Min = 1.0;
				}
				else if (this.rdoB.Checked)
				{
					this.U = 1.5;
					this.Min = 21.0;
				}
			}
			else if (this.rdomore.Checked)
			{
				this.strclass = this.rdomore.Text;
				if (this.rdoA.Checked)
				{
					this.U = 75.0;
					this.Min = 2.0;
				}
				else if (this.rdoB.Checked)
				{
					this.U = 1.0;
					this.Min = 55.0;
				}
			}
			else if (this.rdomost.Checked)
			{
				this.strclass = this.rdomost.Text;
				if (this.rdoA.Checked)
				{
					this.U = 50.0;
					this.Min = 3.0;
				}
				else if (this.rdoB.Checked)
				{
					this.U = 0.5;
					this.Min = 89.0;
				}
			}
			this.lbU.Text = this.U.ToString();
			this.lbMin.Text = this.Min.ToString();
			if (this.rdo1.Checked)
			{
				this.K = 1.0;
				this.strsheshi = this.rdo1.Text;
			}
			else if (this.rdo2.Checked)
			{
				this.K = 0.9;
				this.strsheshi = this.rdo2.Text;
			}
			else if (this.rdo3.Checked)
			{
				this.K = 0.7;
				this.strsheshi = this.rdo3.Text;
			}
			else if (this.rdo4.Checked)
			{
				this.K = 0.5;
				this.strsheshi = this.rdo4.Text;
			}
			else if (this.rdo5.Checked)
			{
				this.K = 0.3;
				this.strsheshi = this.rdo5.Text;
			}
			this.lbK.Text = this.K.ToString();
			if (this.tbmj.Text != "")
			{
				this.lbS.Text = this.tbmj.Text.ToString();
				this.S = double.Parse(this.tbmj.Text.ToString());
			}
			if (this.rdoup.Checked)
			{
				this.Q = Math.Round(this.K * this.S / this.U, 2);
				this.lbQ.Text = this.Q.ToString();
			}
			else
			{
				this.Q = Math.Round(1.3 * this.K * this.S / this.U, 2);
				this.lbQ.Text = this.Q.ToString();
			}
			if (this.tbn.Text != "")
			{
				this.N = int.Parse(this.tbn.Text.ToString());
				this.Qe = Math.Round(this.Q / (double)this.N, 2);
				if (this.Qe < this.Min)
				{
					this.Qe = this.Min;
				}
				this.lbQe.Text = this.Qe.ToString();
			}
			Label label = this.lbQ;
			label.Text += str;
			Label label2 = this.lbQe;
			label2.Text += str;
			Label label3 = this.lbMin;
			label3.Text += str;
			this.btnBook.Enabled = true;
			this.btnChoose.Enabled = true;
			this.UserSettingWrite();
			this.rdohand_CheckedChanged(sender, e);
			this.rdocar_CheckedChanged(sender, e);
		}

		private void btnCancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void btnBook_Click(object sender, EventArgs e)
		{
			this.SaveFileDialog();
		}

		private void btnChoose_Click(object sender, EventArgs e)
		{
		}

		private void InitDataGridView()
		{
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn.HeaderText = "灭火器型号";
			dataGridViewTextBoxColumn.Width = 205;
			dataGridViewTextBoxColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
			dataGridViewTextBoxColumn.ReadOnly = true;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn);
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn2.HeaderText = "灭火器级别";
			dataGridViewTextBoxColumn2.SortMode = DataGridViewColumnSortMode.NotSortable;
			dataGridViewTextBoxColumn2.ReadOnly = false;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn2);
			DataGridViewTextBoxColumn dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
			dataGridViewTextBoxColumn3.HeaderText = "数量";
			dataGridViewTextBoxColumn3.SortMode = DataGridViewColumnSortMode.NotSortable;
			dataGridViewTextBoxColumn3.ReadOnly = true;
			this.dataGridView.Columns.Add(dataGridViewTextBoxColumn3);
		}

		private void btnLay_Click(object sender, EventArgs e)
		{
			if (this.dataGridView.SelectedRows.Count == 1)
			{
				FormLayFireExtinguisher formLayFireExtinguisher = new FormLayFireExtinguisher(this.doc, this.fireExtinguisherParam);
				if (formLayFireExtinguisher.ShowDialog() == DialogResult.OK)
				{
					this.fireExtinguisherParam = formLayFireExtinguisher.fireExtinguisherParam;
					this.layTerminalType = formLayFireExtinguisher.layTerminalType;
					base.DialogResult = DialogResult.OK;
				}
			}
		}

		private void rdohand_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdohand.Checked)
			{
				this.listfe = this.sfdr.GetFireExtinguisherData("FireExtinguisherData", "手提式");
				if (this.rdojibie.Checked)
				{
					this.InitDataByJiBie();
					return;
				}
				this.InitDataAll();
			}
		}

		private void rdocar_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdocar.Checked)
			{
				this.listfe = this.sfdr.GetFireExtinguisherData("FireExtinguisherData", "推车式");
				if (this.rdojibie.Checked)
				{
					this.InitDataByJiBie();
					return;
				}
				this.InitDataAll();
			}
		}

		private void rdojibie_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdojibie.Checked)
			{
				this.InitDataByJiBie();
				return;
			}
			this.InitDataAll();
		}

		private void InitDataByJiBie()
		{
			this.dataGridView.Rows.Clear();
			if (this.listfe.Count > 0)
			{
				foreach (FireExtinguisherClass fireExtinguisherClass in this.listfe)
				{
					if (this.isA && fireExtinguisherClass.LevelA != "")
					{
						double num = double.Parse(fireExtinguisherClass.LevelA.Remove(fireExtinguisherClass.LevelA.Count<char>() - 1));
						if (num >= this.Min)
						{
							int num2 = Convert.ToInt32(Math.Ceiling(this.Qe / num));
							object[] values = new object[]
							{
								fireExtinguisherClass.Model + "(" + fireExtinguisherClass.Agent + ")",
								fireExtinguisherClass.LevelA,
								num2
							};
							this.dataGridView.Rows.Add(values);
						}
					}
					else if (!this.isA && fireExtinguisherClass.LevelB.Count<char>() > 1)
					{
						double num3 = double.Parse(fireExtinguisherClass.LevelB.Remove(fireExtinguisherClass.LevelB.Count<char>() - 1));
						if (num3 >= this.Min)
						{
							int num2 = Convert.ToInt32(Math.Ceiling(this.Qe / num3));
							object[] values2 = new object[]
							{
								fireExtinguisherClass.Model + "(" + fireExtinguisherClass.Agent + ")",
								fireExtinguisherClass.LevelB,
								num2
							};
							this.dataGridView.Rows.Add(values2);
						}
					}
				}
			}
		}

		private void InitDataAll()
		{
			this.dataGridView.Rows.Clear();
			if (this.listfe.Count > 0)
			{
				foreach (FireExtinguisherClass fireExtinguisherClass in this.listfe)
				{
					if (this.isA && fireExtinguisherClass.LevelA != "")
					{
						double num = double.Parse(fireExtinguisherClass.LevelA.Remove(fireExtinguisherClass.LevelA.Count<char>() - 1));
						int num2 = Convert.ToInt32(Math.Ceiling(this.Qe / num));
						object[] values = new object[]
						{
							fireExtinguisherClass.Model + "(" + fireExtinguisherClass.Agent + ")",
							fireExtinguisherClass.LevelA,
							num2
						};
						this.dataGridView.Rows.Add(values);
					}
					else if (!this.isA && fireExtinguisherClass.LevelB.Count<char>() > 1)
					{
						double num3 = double.Parse(fireExtinguisherClass.LevelB.Remove(fireExtinguisherClass.LevelB.Count<char>() - 1));
						int num2 = Convert.ToInt32(Math.Ceiling(this.Qe / num3));
						object[] values2 = new object[]
						{
							fireExtinguisherClass.Model + "(" + fireExtinguisherClass.Agent + ")",
							fireExtinguisherClass.LevelB,
							num2
						};
						this.dataGridView.Rows.Add(values2);
					}
				}
			}
		}

		private void dataGridView_SelectionChanged(object sender, EventArgs e)
		{
			if (this.rdohand.Checked)
			{
				this.fireExtinguisherParam.SymbolName = "手提式";
			}
			else
			{
				this.fireExtinguisherParam.SymbolName = "推车式";
			}
			this.fireExtinguisherParam.JiBie = this.dataGridView.CurrentRow.Cells[1].Value.ToString();
			this.fireExtinguisherParam.Count = (int)this.dataGridView.CurrentRow.Cells[2].Value;
			this.fireExtinguisherParam.XingHao = this.dataGridView.CurrentRow.Cells[0].Value.ToString();
		}

		private void btnArea_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Abort;
		}

		private void SaveFileDialog()
		{
			SaveFileDialog saveFileDialog = new SaveFileDialog();
			saveFileDialog.FileName = "灭火器计算";
			saveFileDialog.Filter = "Word 97-2003 文档|*.doc";
			saveFileDialog.FilterIndex = 1;
			saveFileDialog.RestoreDirectory = true;
			try
			{
				if (saveFileDialog.ShowDialog() == DialogResult.OK)
				{
					string text = saveFileDialog.FileName.ToString();
					this.createWord(text);
					if (MessageBox.Show("是否现在查看？", "盈建科提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
					{
						Process.Start(text);
					}
				}
			}
			catch (Exception ex)
			{
				YJKMessageBox.Show(ex.Message + "请更换一下另存文件的名称或者先关闭此文件");
			}
		}

		private void createWord(object filepath)
		{
			Microsoft.Office.Interop.Word.Application application = (Microsoft.Office.Interop.Word.Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("000209FF-0000-0000-C000-000000000046")));
			this.strFileName = filepath;
			if (File.Exists((string)this.strFileName))
			{
				File.Delete((string)this.strFileName);
			}
			object value = Missing.Value;
            Microsoft.Office.Interop.Word.Document document = application.Documents.Add(ref value, ref value, ref value, ref value);
			string text = "地面以上建筑计算单元的最小需配灭火级别计算公式:\nQ = K * (S / U)\n";
			string text2 = "地下建筑计算单元的最小需配灭火级别计算公式:\nQ = 1.3K * (S / U)\n";
			string text3 = "式中U的取值见下表:\nA类火灾场所灭火器的最低配置基准";
			string text4 = "式中U的取值见下表:\nB类火灾场所灭火器的最低配置基准";
			string str;
			if (this.rdoup.Checked)
			{
				str = text;
			}
			else
			{
				str = text2;
			}
			string text5;
			if (this.rdoA.Checked)
			{
				text5 = text3;
				this.strAB = this.rdoA.Text;
				this.strU = "(m2/A)";
				this.strdanwei = "A";
			}
			else
			{
				text5 = text4;
				this.strAB = this.rdoB.Text;
				this.strU = "(m2/B)";
				this.strdanwei = "B";
			}
			document.Paragraphs.Add(ref value);
			document.Paragraphs.Last.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
			document.Paragraphs.Last.Range.Text = "灭火器的灭火等级计算\n";
			document.Paragraphs.Add(ref value);
			document.Paragraphs.Last.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			document.Paragraphs.Last.Range.Text = "依据<<建筑灭火器配置设计规范(GB50140-2005)>>\n" + str + "Q - 计算单元的最小需配灭火级别(A或B)\nS - 计算单元的保护面积(m2)\nU - A类或B类火灾场所单位灭火级别最大保护面积(m2/A 或 m2/B)\nK - 修正系数\n\n修正系数";
			object obj = WdUnits.wdParagraph;
			object obj2 = 13;
            Microsoft.Office.Interop.Word.Selection selection = application.Selection;
			object obj3 = value;
			selection.MoveDown(ref obj, ref obj2, ref obj3);
			Table table = document.Tables.Add(application.Selection.Range, 6, 2, ref value, ref value);
			table.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
			table.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
			table.Columns[1].Width = 200f;
			table.Columns[2].Width = 50f;
			table.Cell(1, 1).Range.Text = "计算单元";
			table.Cell(1, 2).Range.Text = "K";
			application.Selection.Cells.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter;
			application.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			table.Cell(2, 1).Range.Text = "未设室内消火栓系统和灭火系统";
			table.Cell(2, 2).Range.Text = "1";
			table.Cell(3, 1).Range.Text = "设有室内消火栓系统";
			table.Cell(3, 2).Range.Text = "0.9";
			table.Cell(4, 1).Range.Text = "设有灭火系统";
			table.Cell(4, 2).Range.Text = "0.7";
			table.Cell(5, 1).Range.Text = "设有室内消火栓系统和灭火系统";
			table.Cell(5, 2).Range.Text = "0.5";
			table.Cell(6, 1).Range.Text = "可燃物露天堆场\n甲、乙、丙类液体储罐区\n可燃气体储罐区";
			table.Cell(6, 2).Range.Text = "0.3";
			application.Selection.Cells.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter;
			document.Paragraphs.Add(ref value);
			document.Paragraphs.Last.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			document.Paragraphs.Last.Range.Text = text5;
			obj = WdUnits.wdParagraph;
			obj2 = 24;
			application.Selection.MoveDown(ref obj, ref obj2, ref value);
			Table table2 = document.Tables.Add(application.Selection.Range, 3, 4, ref value, ref value);
			table2.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleSingle;
			table2.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle;
			table2.Columns[1].Width = 200f;
			table2.Columns[2].Width = 100f;
			table2.Columns[3].Width = 100f;
			table2.Columns[4].Width = 100f;
			table2.Cell(1, 1).Range.Text = "危险等级";
			table2.Cell(1, 2).Range.Text = "严重危险等级";
			table2.Cell(1, 3).Range.Text = "中危险等级";
			table2.Cell(1, 4).Range.Text = "轻危险等级";
			if (this.rdoA.Checked)
			{
				table2.Cell(2, 1).Range.Text = "单具灭火器最小配置灭火级别";
				table2.Cell(2, 2).Range.Text = "3A";
				table2.Cell(2, 3).Range.Text = "2A";
				table2.Cell(2, 4).Range.Text = "1A";
				table2.Cell(3, 1).Range.Text = "单位灭火级别最大保护面积(m2/A)";
				table2.Cell(3, 2).Range.Text = "50";
				table2.Cell(3, 3).Range.Text = "75";
				table2.Cell(3, 4).Range.Text = "100";
			}
			else
			{
				table2.Cell(2, 1).Range.Text = "单具灭火器最小配置灭火级别";
				table2.Cell(2, 2).Range.Text = "89B";
				table2.Cell(2, 3).Range.Text = "55B";
				table2.Cell(2, 4).Range.Text = "21B";
				table2.Cell(3, 1).Range.Text = "单位灭火级别最大保护面积(m2/B)";
				table2.Cell(3, 2).Range.Text = "0.5";
				table2.Cell(3, 3).Range.Text = "1.0";
				table2.Cell(3, 4).Range.Text = "1.5";
			}
			document.Paragraphs.Add(ref value);
			document.Paragraphs.Last.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			document.Paragraphs.Last.Range.Text = string.Concat(new string[]
			{
				"灭火配置场所的保护面积：S =",
				this.S.ToString(),
				"平方米\n危险等级,火灾级别：",
				this.strclass,
				",",
				this.strAB,
				"\n单位灭火级别最大保护面积：U =",
				this.lbU.Text,
				this.strU,
				"\n灭火设施情况：",
				this.strsheshi,
				"\n修正系数：",
				this.K.ToString(),
				"\n"
			});
			document.Paragraphs.Add(ref value);
			document.Paragraphs.Last.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
			document.Paragraphs.Last.Range.Text = string.Concat(new string[]
			{
				"计算结果：\n灭火器配置所需的灭火级别：",
				this.Q.ToString(),
				this.strdanwei,
				"\n单个设置点儿的灭火级别：",
				this.Qe.ToString(),
				this.strdanwei,
				"\n单具灭火器最小配置灭火级别：",
				this.Min.ToString(),
				this.strdanwei
			});
			document.SaveAs(ref this.strFileName, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value, ref value);
			document.Close(ref value, ref value, ref value);
			application.Quit(ref value, ref value, ref value);
		}

		private void initParameterSetting()
		{
			this.dic = this.userSetting.GetFireExtinguisherCalSetting();
			string valueFromDic = this.userSetting.GetValueFromDic("dishang", "0", this.dic);
			string valueFromDic2 = this.userSetting.GetValueFromDic("leibie", "0", this.dic);
			string valueFromDic3 = this.userSetting.GetValueFromDic("jibie", "0", this.dic);
			string valueFromDic4 = this.userSetting.GetValueFromDic("changdi", "0", this.dic);
			string valueFromDic5 = this.userSetting.GetValueFromDic("mianji", "2000", this.dic);
			string valueFromDic6 = this.userSetting.GetValueFromDic("count", "5", this.dic);
			if (!(valueFromDic == "0"))
			{
				if (valueFromDic == "1")
				{
					this.rdodown.Checked = true;
				}
			}
			else
			{
				this.rdoup.Checked = true;
			}
			if (!(valueFromDic2 == "0"))
			{
				if (valueFromDic2 == "1")
				{
					this.rdoB.Checked = true;
				}
			}
			else
			{
				this.rdoA.Checked = true;
			}
			if (!(valueFromDic3 == "0"))
			{
				if (!(valueFromDic3 == "1"))
				{
					if (valueFromDic3 == "2")
					{
						this.rdomost.Checked = true;
					}
				}
				else
				{
					this.rdomore.Checked = true;
				}
			}
			else
			{
				this.rdomuch.Checked = true;
			}
			if (!(valueFromDic4 == "0"))
			{
				if (!(valueFromDic4 == "1"))
				{
					if (!(valueFromDic4 == "2"))
					{
						if (!(valueFromDic4 == "3"))
						{
							if (valueFromDic4 == "4")
							{
								this.rdo5.Checked = true;
							}
						}
						else
						{
							this.rdo4.Checked = true;
						}
					}
					else
					{
						this.rdo3.Checked = true;
					}
				}
				else
				{
					this.rdo2.Checked = true;
				}
			}
			else
			{
				this.rdo1.Checked = true;
			}
			this.tbmj.Text = valueFromDic5;
			this.tbn.Text = valueFromDic6;
		}

		private void UserSettingWrite()
		{
			try
			{
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				string value = "";
				if (this.rdoup.Checked)
				{
					value = "0";
				}
				else if (this.rdodown.Checked)
				{
					value = "1";
				}
				dictionary.Add("dishang", value);
				string value2 = "";
				if (this.rdoA.Checked)
				{
					value2 = "0";
				}
				else if (this.rdoB.Checked)
				{
					value2 = "1";
				}
				dictionary.Add("leibie", value2);
				string value3 = "";
				if (this.rdomuch.Checked)
				{
					value3 = "0";
				}
				else if (this.rdomore.Checked)
				{
					value3 = "1";
				}
				else if (this.rdomost.Checked)
				{
					value3 = "2";
				}
				dictionary.Add("jibie", value3);
				string value4 = "";
				if (this.rdo1.Checked)
				{
					value4 = "0";
				}
				else if (this.rdo2.Checked)
				{
					value4 = "1";
				}
				else if (this.rdo3.Checked)
				{
					value4 = "2";
				}
				else if (this.rdo4.Checked)
				{
					value4 = "3";
				}
				else if (this.rdo5.Checked)
				{
					value4 = "4";
				}
				dictionary.Add("changdi", value4);
				dictionary.Add("mianji", this.tbmj.Text.Trim());
				dictionary.Add("count", this.tbn.Text.Trim());
				this.userSetting.WriteFireExtinguisherCalSetting(dictionary);
			}
			catch (Exception)
			{
			}
		}

		public void GetProtectArea()
		{
			ElementSet elementSet = new ElementSet();
			XYZ xyz = this.sel.PickPoint("请选择绘制线段的起点……");
			double num = 0.0;
			int num2 = 0;
            Autodesk.Revit.DB.Line line = null;
            Autodesk.Revit.DB.Line line2 = null;
			List<XYZ> list = new List<XYZ>();
			list.Add(xyz);
			for (;;)
			{
				try
				{
					XYZ xyz2 = this.sel.PickPoint("请选择绘制线段的终点……");
					if (!xyz.IsAlmostEqualTo(xyz2))
					{
						list.Add(xyz2);
						DetailLine detailLine = YJKRevitTools.DrawDetailLine(this.doc, xyz, xyz2);
						elementSet.Insert(detailLine);
						num2++;
						num += Math.Round((detailLine.Location as LocationCurve).Curve.Length * 0.3048, 3);
						if (num2 % 2 == 0)
						{
                            line2 = ((detailLine.Location as LocationCurve).Curve as Autodesk.Revit.DB.Line);
						}
						else if (num2 % 2 == 1)
						{
                            line = ((detailLine.Location as LocationCurve).Curve as Autodesk.Revit.DB.Line);
						}
						if (num2 >= 2 && line2 != null && line != null)
						{
							Math.Round(line.Length * 0.3048, 3);
							Math.Round(line2.Length * 0.3048, 3);
							line.Direction.AngleTo(line2.Direction);
							double num3 = Math.Round(YJKRevitTools.CalArea(list) * 0.3048 * 0.3048, 3);
							this.tbmj.Text = num3.ToString();
						}
						xyz = xyz2;
						continue;
					}
					MessageBox.Show("不能选择两个重合的点！", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				catch (Autodesk.Revit.Exceptions.OperationCanceledException)
				{
				}
				break;
			}
			this.DeleteDatailLines(elementSet);
		}

		private bool DeleteDatailLines(ElementSet detailLines)
		{
			if (detailLines.Size < 1)
			{
				return false;
			}
			IEnumerator enumerator = detailLines.GetEnumerator();
			bool flag = enumerator.MoveNext();
			while (flag)
			{
				Element element = enumerator.Current as Element;
				this.doc.Delete(element.Id);
				flag = enumerator.MoveNext();
			}
			return true;
		}

		private double Q = 100.0;

		private double S = 200.0;

		private double U = 50.0;

		private double K = 1.0;

		private double Min = 1.0;

		private int N = 2;

		private double Qe = 1.0;

		private bool isA = true;

		private object strFileName;

		private string strclass = "";

		private string strAB = "";

		private string strU = "";

		private string strsheshi = "";

		private string strdanwei = "";

		public FireExtinguisherParam fireExtinguisherParam = new FireExtinguisherParam();

		private HVACUserSetting userSetting = new HVACUserSetting();

        private Autodesk.Revit.DB.Document doc;

        private Autodesk.Revit.UI.Selection.Selection sel;

		public int layTerminalType;

		private Dictionary<string, string> dic;

		private SpaceFamilyDataReader sfdr = new SpaceFamilyDataReader();

		private List<FireExtinguisherClass> listfe = new List<FireExtinguisherClass>();
	}
}
